1. Field of the Invention
The invention relates to a method and apparatus for accessing a memory, and more particularly, to a method and apparatus for accessing a ring buffer memory.
2. Description of the Prior Art
Please refer to FIG. 1. FIG. 1 is an exemplary block diagram of an optical disc drive 10. The optical disc drive 10 comprises a pickup head 12, a servo controller 14, a write signal generating unit 16, a recorded data generating unit 18, an encoder 22, a decoder 24, a comparator 26 and a memory 28. The servo controller 14 drives the pickup head 12 to read or write data from or to an optical disc 20. The memory 28 stores data. The data stored in the memory 28 are encoded by the encoder 22 to form an encoded recording data. The write signal generating unit 16 receives the encoded recording data and outputs a write signal to the pickup head 12 for recording the data onto an optical disc 20.
The recorded data generating unit 18 receives a modulated recorded data signal from the pickup head 12 and generates an encoded recorded data. The encoded recorded data are decoded by the decoder 24 to output recorded data. The comparator 26 compares the recorded data with the data stored in the memory 28 to verify the correctness of the recorded data.
The memory 28, such as a ring buffer, is divided into multiple blocks. Each block serves as a basic unit for storing the data. The data are stored into the memory 28 block by block, and are outputted from the memory block by block. The data of each block of the memory 28 is to be recorded in a destination address of the optical disc 20. In general, the data to be recorded on sequential destination addresses will be sequentially stored in the adjacent blocks of the memory 28. Then, when recording the data, the data could be read out from the memory 28 in sequence, thereby the pickup head 12 of the optical disc drive 10 could sequentially move around the optical disc 20.
Sequentially read/write data from/to the optical disc is more efficiency for an optical disc drive. However, the data stored in successive blocks of the memory 28 may not have destination address information. Therefore, when the data stored in successive blocks are sequentially outputted from the memory 28, the optical disc drive 10 may frequently move the pickup head 12 back and forth around the surface of the optical disc 20. Thus the efficiency of the recording operating is limited.
For a recordable optical disc, a certain location on the recordable optical disc could be perceived as a “defect”, caused by scratch, finger print, damage to the surface of the optical disc, or a change in the material characteristic of the optical disc. The specific location, i.e. defective part, corresponding to the defect cannot be utilized for storing data correctly. Therefore, the defect management is proposed in the optical disc specification. One of the most popular defect management provides a spare area on the optical disc. As a result, when a defective part is identified, the data that is originally to be recorded in the defective part will be recoded into the spare area of the optical disc. Thus, the recording function of the optical disc will not be influenced by the defect.
Please refer to FIG. 2 to FIG. 4. FIG. 2 to FIG. 4 are schematic views of managing buffered data with respect to the defect management of the optical disc drive. As Shown in FIG. 1 and FIG. 2 the optical disc 20 comprises a data area and a spare area. The data stored in the memory 28 are successively recorded onto the destination addresses of the data area. If a defective part of the data area is identified, the data that is originally designed to be recorded in the defective part will be further recoded onto the spare area. Please refer to FIG. 1 and FIG. 3. In order to support the defect management and also maintain the recording efficiency, the memory 28 of the optical disc drive comprises a main buffer 281 and a second buffer 282. The data are initially stored in the main buffer 281. When defective part of the data area is identified, the data of the defective parts are stored in the second buffer 282 for the sake of sequentially recording the data of the defective part onto the spare area. The write signal generating unit 16 generates the write signal according the data received from the main buffer 281, and outputs the write signal to the pickup head 12. So that the pickup head 12 moves to the destination address of the data area and emits laser light according to the write signal to record the data to the data areas of the optical disc 20. In addition, the pickup head 12 moves to the spare area of the optical disc 20 and emits laser light to the spare area according to the write signal generated from the data stored in the second buffer 282.
As shown in FIG. 4, the data recorded on the optical disc 20 (i.e. recorded data) are verified to check the correctness of the recorded data by reading the recorded data to compare with the data stored in the memory 28. For the data recorded in the spare area, the optical disc drive 10 moves the pickup head 12 to the spare area, and then generates the recorded data. The comparator 26 compares the recorded data received from the recorded data generating unit 18 and the data stored in the second buffer 282 so as to verify the recording correctness.